/**
 * Description: 登录
 *
 * @author      Eden
 * @datetime    2016/11/25 09:30
 * @copyright   Beijing CmsTop Technology Co.,Ltd.
 */

(function () {
    "use strict";

    var api = {
        compBillUrl: "/bill/purchaser/comp"
    };

    sm.controller('admin-money-purchaser-detail', ['$scope', '$http', 'Modal', function ($scope, $http, Modal) {

        $scope.complete = function(id, baseId) {
            if (!id || !baseId) {
                return false;
            }

            Modal.alert({
                title: "操作提示",
                content: "您确定将此申请置为完成状态？",
                buttons: [{
                    name: "取消"
                }, {
                    name: "确认",
                    event: function () {
                        doComp(id, baseId);
                    }
                }]
            });
        };

        function doComp(id, baseId) {
            $http.get(api.compBillUrl, {
                params: {
                    id: id
                }
            }).success(function (res) {
                if (res.state) {
                    location.href = '/bill/history/index?baseId=' + baseId;
                } else {
                    Modal.error('操作失败');
                }
            });
        }


    }]);

})();

